package com.sk.sqd.strategy;

import org.springframework.stereotype.Component;

import java.math.BigDecimal;

/**
 * 打折收费算法，初始化传入折扣，返回打折后金额
 */
@Component
public class CashRebateStrategy extends CashStrategy {

    @Override
    public BigDecimal acceptCash(BigDecimal money, Double moneyRebate, Double moneyCondition, Double moneyReturn) {
        return money.multiply(BigDecimal.valueOf(moneyRebate > 0 ? moneyRebate : 1.0d)).setScale(2);
    }

    @Override
    public String type() {
        return "rebate";
    }

}
